#include "RingQueue.hpp"
#include "Log.hpp"

void* productor(void* args)
{
    RingQueue<int>* rq = static_cast<RingQueue<int>*>(args);
    int cnt = 0;
    while(true)
    {
        rq->put(cnt);
        std::cout << "put: " << cnt-- << std::endl;
        sleep(1);
    }
}

void* consumer(void* args)
{
    RingQueue<int>* rq = static_cast<RingQueue<int>*>(args);
    while(true)
    {
        int data = 0;
        rq->take(&data);
        std::cout << "take: " << data << std::endl;
    }
}

int main()
{
    pthread_t c, p;

    RingQueue<int>* rq = new RingQueue<int>();

    pthread_create(&c, nullptr, productor, rq);
    pthread_create(&p, nullptr, consumer, rq);

    pthread_join(c, nullptr);
    pthread_join(p, nullptr);

    return 0;
}